Install necessary packages

#install.packages("plotly")
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

1. Load in Data for target species

load("Prediction_Data.Rdata") #The raw IntaRNA energy table for the target species
load("Top_Proteins_DF.Rdata") #Top miRNA and targeting score for each protein in the target pathogen
load("Energy_HM_Data.Rdata") #Energy scores for interactions between top 10% of miRNAs and all proteins in target pathogen

2. Calculate summary statistics for energy scores of each human miRNA across all genes in the target pathogen

#'Top miRNAs' panel in 'Summary View' of Rocket-miR application
IntaRNA_Data <- PG_Prediction_Data[,c(1:630)]
Top_miRNAs_DF <- data.frame(unlist(apply(IntaRNA_Data, 2, mean, na.rm = TRUE)), 
                            unlist(apply(IntaRNA_Data, 2, median, na.rm = TRUE)),
                            unlist(apply(IntaRNA_Data, 2, min, na.rm = TRUE)))
colnames(Top_miRNAs_DF) <- c("Mean Energy Score", "Median Energy Score", "Minimum Energy Score")
Top_miRNAs_DF[order(Top_miRNAs_DF$`Mean Energy Score`),]

3. Visualize all individual targeting scores for each gene by all miRNAs

#'Energy Score Heat Map' panel in 'Summary View' of Rocket-miR application
plot_ly(z = as.matrix(Energy_HM_Data), type = "heatmap"
                    ) %>% layout(plot_bgcolor='#e5ecf6',
                                 xaxis = list(
                                   title='miRNA',
                                   zerolinecolor = '#ffff',
                                   zerolinewidth = 2,
                                   gridcolor = 'ffff',
                                   showticklabels = FALSE),
                                 yaxis = list(
                                   title='Protein Target',
                                   zerolinecolor = '#ffff',
                                   zerolinewidth = 2,
                                   gridcolor = 'ffff',
                                   showticklabels = FALSE)) %>%
                      add_trace(type = "heatmap", x = colnames(Energy_HM_Data[,c(1:63)]), y = Energy_HM_Data[,64]) %>%
                      hide_colorbar()
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning: `textfont.color` does not currently support multiple values.

## Warning: `textfont.color` does not currently support multiple values.
#Note: In this version of the plot, a darker blue color indicates a stronger energy score, while a darker red color indicates a weaker energy score

4. Identify the individual miRNA predicted to best target each individual protein

#'Top Targeted Proteins' panel in 'Summary View' of Rocket-miR application
Top_Proteins_DF[order(Top_Proteins_DF$`Best Energy Score`),]